/*              Copyright(c) 2008 Dave Sexton              *
 * http://www.codeplex.com/DocProject                      *
 * http://www.codeplex.com/DocProject/Project/License.aspx *
 ***********************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.ObjectModel;
using DaveSexton.DocProject;
using DaveSexton.DocProject.Sandcastle;

namespace DaveSexton.Sandcastle
{
	internal sealed class ApiReferenceCollection : Collection<ApiReference>
	{
		#region Public Properties
		#endregion

		#region Private / Protected
		private readonly ReflectionDocument document;
		private bool loaded;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructs a new instance of the <see cref="ApiReferenceCollection" /> class.
		/// </summary>
		public ApiReferenceCollection(ReflectionDocument document)
		{
			if (document == null)
				throw new ArgumentNullException("document");

			this.document = document;
		}
		#endregion

		#region Methods
		public void EnsureLoaded()
		{
			if (!loaded)
			{
				document.Load();

				document.ForEachApiElement(delegate(ReflectionApiElement element)
				{
					Add(new ApiReference(element));
				});

				loaded = true;
			}
		}
		#endregion
	}
}
